#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<string>
#include<cstring>

using namespace std;

string makeSmallestPalindrome(string s) {
    int l = 0, r = s.size() - 1;
    while (l <= r)
    {
        if (s[l] != s[r])
        {
            if (s[l] < s[r])
                s[r] = s[l];
            else
                s[l] = s[r];
        }
        l++, r--;
    }
    return s;
}

const int N = 20, M = 1 << 20;

int n;
int f[M][N], weight[N][N];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> weight[i][j];

    memset(f, 0x3f, sizeof f);
    f[1][0] = 0;

    for (int i = 0; i < 1 << n; i++)
        for (int j = 0; j < n; j++)
            if (i >> j & 1)
                for (int k = 0; k < n; k++)
                    if (i >> k & 1)
                        f[i][j] = min(f[i][j], f[i - (1 << j)][k] + weight[k][j]);

    cout << f[(1 << n) - 1][n - 1];
    return 0;
}